//
//  JFTabBarController.swift
//  BaoKanIOS
//
//  Created by jianfeng on 15/12/20.
//  Copyright © 2015年 六阿哥. All rights reserved.
//

import UIKit

class JFTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 配置tabBar图标颜色
//        tabBar.tintColor = NAVIGATIONBAR_RED_COLOR
        
        // 添加所有子控制器
        addAllChildViewController()
    }
    
    /**
     添加所有子控制器
     */
    fileprivate func addAllChildViewController() {
       
//        let kHomeVc = JFNavigationController.init(rootViewController: KHomeListViewController())
//        addChildViewController(kHomeVc, title: "主页", imageName: "tabbar_icon_media")
//        
//        let vc1 = JFNavigationController.init(rootViewController: KKCategoryViewController())
//        addChildViewController(vc1, title: "分类", imageName: "tabbar_icon_media")
//        
//        
//        let vc = JFNavigationController.init(rootViewController: KKMainViewController())
//        addChildViewController(vc, title: "首页", imageName: "tabbar_icon_media")
        
      
    }
    
    /**
     配置添加子控制器
     
     - parameter childController: 控制器
     - parameter title:           标题
     - parameter imageName:       图片
     */
    fileprivate func addChildViewController(_ childController: UIViewController, title: String, imageName: String) {
        
        
        childController.title = title
        childController.tabBarItem.title = title
//        childController.tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3)
        childController.tabBarItem.setTitleTextAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 14)], for: UIControlState())
        childController.tabBarItem.image = UIImage(named: "\(imageName)_normal")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_highlight")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        addChildViewController(childController)
    }
    
}
